package cn.funnyxb.powerremember.uis.task.taskMain;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;
import cn.funnyxb.powerremember.beans.ATask;
import cn.funnyxb.powerremember.beans.StudyLog;
import cn.funnyxb.powerremember.uis.task.done.autobrow.AutoBrowActivity;
import cn.funnyxb.powerremember.uis.task.done.study.StudyActivity;
import cn.funnyxb.tools.appFrame.App;
import cn.funnyxb.tools.appFrame.activityFrame.ActivitysHolder;
import cn.funnyxb.tools.appFrame.debugTool.Debuger;
import cn.funnyxb.tools.appFrame.util.DatetimeTool;
import com.mobclick.android.MobclickAgent;
import java.util.ArrayList;

public class TaskMainActivity extends Activity
  implements IUI_TaskMain
{
  public static final String EXTRA_TASKINFO = "taskinfo";
  private static final int REQUESTCODE_STUDY = 1;
  private View.OnClickListener btnOnclickListener = new 1(this);
  private StudyLog lastStudyLog = null;
  private ArrayList<Integer> learnedGroups = null;
  private IProccessor_TaskMain proccessor;
  ProgressDialog progressDialog;
  private ATask taskInfo;

  private void checkTaskInfo()
  {
    try
    {
      this.taskInfo = ((ATask)getIntent().getSerializableExtra("taskinfo"));
      if (this.taskInfo == null)
        errCall();
      return;
    }
    catch (Exception localException)
    {
      errCall();
    }
  }

  private void dismissWaittingDialog()
  {
    if (this.progressDialog == null)
      return;
    this.progressDialog.dismiss();
  }

  private void errCall()
  {
    Toast.makeText(this, 2131034147, 1).show();
    finish();
  }

  private void freashDynamicDataOnUI(int paramInt, StudyLog paramStudyLog)
  {
    ((TextView)findViewById(2131165343)).setText(getString(2131034290) + ": " + paramInt + getString(2131034149));
    findViewById(2131165345).setVisibility(0);
    findViewById(2131165347).setVisibility(0);
    if (paramStudyLog != null)
      ((TextView)findViewById(2131165345)).setText(getString(2131034291) + ": " + getString(2131034160) + paramStudyLog.getGroupId() + getString(2131034149) + "(" + DatetimeTool.getDelaysInCn(paramStudyLog.getDatetime() + paramStudyLog.getCostTime()) + ")");
    int i;
    String str2;
    while (true)
    {
      i = getSurpassOfGroup(paramInt);
      if (i != 0)
        break;
      str2 = getString(2131034299);
      label177: ((TextView)findViewById(2131165346)).setText(getString(2131034292) + ": " + str2);
      return;
      ((TextView)findViewById(2131165345)).setText(getString(2131034291) + ": " + getString(2131034296));
      findViewById(2131165347).setVisibility(8);
    }
    if (i > 0);
    for (String str1 = getString(2131034297); ; str1 = getString(2131034298))
    {
      str2 = str1 + Math.abs(i) + getString(2131034149);
      break label177:
    }
  }

  private void freashStaticDataOnUI()
  {
    ((TextView)findViewById(2131165340)).setText(getString(2131034287) + ": " + this.taskInfo.getWordCnt());
    ((TextView)findViewById(2131165341)).setText(getString(2131034289) + ": " + getString(2131034294) + this.taskInfo.getGroupSize() + "," + getString(2131034159) + (int)Math.ceil((0.0D + this.taskInfo.getWordCnt()) / this.taskInfo.getGroupSize()) + getString(2131034149));
    ((TextView)findViewById(2131165342)).setText(getString(2131034289) + ": " + getString(2131034295) + this.taskInfo.getGroupOfOneDay() + getString(2131034149));
  }

  private void freashStudyLogOfGroup(ArrayList<Integer> paramArrayList)
  {
    log("hasLearned, hasStudyedGroups=" + paramArrayList);
    if (paramArrayList == null)
      findViewById(2131165347).setVisibility(8);
    while (true)
    {
      return;
      log("hasLearned, cnt=" + paramArrayList.size() + ",they are=" + paramArrayList.toString());
      findViewById(2131165347).setVisibility(0);
      ((TextView)findViewById(2131165347)).setText(getString(2131034293) + ":" + paramArrayList.toString());
    }
  }

  private int getSurpassOfGroup(int paramInt)
  {
    return (paramInt - ((int)Math.ceil((0.0D + System.currentTimeMillis() - this.taskInfo.getCreateDatetime()) / 86400000.0D) * this.taskInfo.getGroupOfOneDay()));
  }

  private void initFrame()
  {
    setTitle(getString(2131034112) + "--" + getString(2131034283) + "(" + this.taskInfo.getName() + ")");
    freashStaticDataOnUI();
    findViewById(2131165336).setOnClickListener(this.btnOnclickListener);
    findViewById(2131165337).setOnClickListener(this.btnOnclickListener);
  }

  private boolean isLearnedGroup(int paramInt)
  {
    if ((this.learnedGroups == null) || (this.learnedGroups.size() == 0));
    boolean bool;
    for (int i = 0; ; i = bool)
    {
      return i;
      bool = this.learnedGroups.contains(Integer.valueOf(paramInt));
      log("learned=" + bool);
    }
  }

  private void log(String paramString)
  {
    Debuger.log("taskmain", paramString);
  }

  private void showWaittingDialog()
  {
    if (this.progressDialog == null)
      this.progressDialog = new ProgressDialog(this);
    this.progressDialog.setMessage(getString(2131034132));
    this.progressDialog.setCancelable(false);
    this.progressDialog.show();
  }

  private void startStudyActivity(Class<?> paramClass, int paramInt)
  {
    if (paramClass == null)
      label4: return;
    Intent localIntent = new Intent(this, paramClass);
    localIntent.putExtra("atask", this.taskInfo);
    localIntent.putExtra("rangetype", 1);
    localIntent.putExtra("groupid", paramInt);
    int i = 10;
    if (paramClass.equals(StudyActivity.class))
      if (isLearnedGroup(paramInt))
        i = 30;
    do
      while (true)
      {
        label71: localIntent.putExtra("studytype", i);
        startActivityForResult(localIntent, 1);
        break label4:
        i = 10;
      }
    while (!(paramClass.equals(AutoBrowActivity.class)));
    if (isLearnedGroup(paramInt));
    for (i = 40; ; i = 20)
      break label71:
  }

  public void notifyDataLoaded(ATask paramATask, ArrayList<Integer> paramArrayList, StudyLog paramStudyLog)
  {
    if ((isFinishing()) || (isRestricted()))
      label14: return;
    log("notify: learned=" + paramArrayList);
    this.taskInfo = paramATask;
    this.lastStudyLog = paramStudyLog;
    this.learnedGroups = paramArrayList;
    if (paramArrayList == null);
    for (int i = 0; ; i = paramArrayList.size())
    {
      freashDynamicDataOnUI(i, paramStudyLog);
      freashStudyLogOfGroup(paramArrayList);
      dismissWaittingDialog();
      break label14:
    }
  }

  public void notifyWaitingLoadData()
  {
    if ((isFinishing()) || (isRestricted()));
    while (true)
    {
      return;
      showWaittingDialog();
    }
  }

  protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
  {
    super.onActivityResult(paramInt1, paramInt2, paramIntent);
    this.proccessor.asyncLoadData(this.taskInfo.getId(), 500L);
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    log("oncreate");
    checkTaskInfo();
    this.proccessor = new Proccessor_TaskMain(this);
    setContentView(2130903055);
    initFrame();
    this.proccessor.asyncLoadData(this.taskInfo.getId(), 0L);
  }

  protected void onDestroy()
  {
    log("destroy");
    this.proccessor.destroy();
    super.onDestroy();
  }

  protected void onPause()
  {
    super.onPause();
    MobclickAgent.onPause(this);
  }

  protected void onResume()
  {
    log("resume");
    super.onResume();
    MobclickAgent.onResume(this);
    App.getApp().getActivitysHolder().regCurrentActivity(this);
  }

  protected void onStart()
  {
    log("start");
    super.onStart();
  }
}

/* Location:           E:\Desktop\复件 classes_dex2jar.jar
 * Qualified Name:     cn.funnyxb.powerremember.uis.task.taskMain.TaskMainActivity
 * JD-Core Version:    0.5.3
 */